// pages/user-my-task/user-my-task.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgBase: app.globalData.imgUrl,
    localImg: app.globalData.staticimgUrl,
    userInfo: {}, // 用户信息
    paiming: "", // 排名
    taskOther: [], // 其他任务
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.TaskByUser();
  },
  // 获取用户美丽任务
  TaskByUser() {
    const that = this;
    const param = {
      userId: wx.getStorageSync('userid')
    };
    app.request({
      url: 'doctor/memberTaskApi/getMemberTaskByUser',
      data: param,
      success: function(res) {
        console.log("获取用户美丽任务", res);
        that.setData({
          userInfo: res.data.userInfo,
          taskOther: res.data.taskOther,
          taskNew: res.data.taskNew,
          currUser: res.data.currUser,
          paiming: res.data.currUser.rownum,
        })
      },
      fail: function(res) {
        app.requestFail(res);
      }
    });
  },

  //跳转购物，案例
  toFinish(e){
    const type = e.currentTarget.dataset.type;
    type == 1 &&
    wx.navigateTo({
      url: '../doctor-my-case/doctor-my-case?isShowAdd='+1
    });
    
    type == 2 &&
    wx.navigateTo({
      url: '../user-shop-goods/user-shop-goods'
    });
  }
})